d<-read.csv("C://Users/ASUS/Desktop/Descriptive Statistics/Research/country.csv")
d$region<-factor(d$region)
levels(d$region)<-c("Eastern Africa","Middle Africa","Northern Africa","Southern Africa","Western Africa","Caribbean","Central America","South America","North America","Eastern Asia","Southeast Asia","Southern Asia","Western Asia","Eastern Europe","Northern Europe","Southern Europe","Western Europe","Oceania","USSR")
d$develop<-factor(d$develop)
levels(d$develop)<-c("Developing country","Developed country")
library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 3.6.3
res.pca <- PCA(d[,2:10], graph = FALSE)
## Warning in PCA(d[, 2:10], graph = FALSE): Missing values are imputed by the mean
## of the variable: you should use the imputePCA function of the missMDA package
print(res.pca)
## **Results for the Principal Component Analysis (PCA)**
## The analysis was performed on 122 individuals, described by 9 variables
## *The results are available in the following objects:
##
## name description
## 1 "$eig" "eigenvalues"
## 2 "$var" "results for the variables"
## 3 "$var$coord" "coord. for the variables"
## 4 "$var$cor" "correlations variables - dimensions"
## 5 "$var$cos2" "cos2 for the variables"
## 6 "$var$contrib" "contributions of the variables"
## 7 "$ind" "results for the individuals"
## 8 "$ind$coord" "coord. for the individuals"
## 9 "$ind$cos2" "cos2 for the individuals"
## 10 "$ind$contrib" "contributions of the individuals"
## 11 "$call" "summary statistics"
## 12 "$call$centre" "mean of the variables"
## 13 "$call$ecart.type" "standard error of the variables"
## 14 "$call$row.w" "weights for the individuals"
## 15 "$call$col.w" "weights for the variables"
eigenvalues <- res.pca$eig
print(eigenvalues)
## eigenvalue percentage of variance cumulative percentage of variance
## comp 1 6.14036147 68.2262385 68.22624
## comp 2 1.05979242 11.7754714 80.00171
## comp 3 0.83770655 9.3078505 89.30956
## comp 4 0.45823761 5.0915290 94.40109
## comp 5 0.30782358 3.4202621 97.82135
## comp 6 0.09071211 1.0079124 98.82926
## comp 7 0.05284439 0.5871599 99.41642
## comp 8 0.04320697 0.4800775 99.89650
## comp 9 0.00931489 0.1034988 100.00000
barplot(eigenvalues[, 2], names.arg=1:nrow(eigenvalues),
main = "Variances",
xlab = "Principal Components",
ylab = "Percentage of variances",
col ="steelblue")
# Add connected line segments to the plot
lines(x = 1:nrow(eigenvalues), eigenvalues[, 2],
type="b", pch=19, col = "red")
#Make the scree plot using the package factoextra
library(factoextra)
## Warning: package 'factoextra' was built under R version 3.6.1
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.6.1
## Welcome! Related Books: `Practical Guide To Cluster Analysis in R` at https://goo.gl/13EFCZ
fviz_screeplot(res.pca, ncp=10)
From the above Scree plot we find that, we have to select the column no 1 to 10.
data2<-d[1:122,1:10]
print(data2)
## country pop92 urban gdp lifeexpm lifeexpf birthrat
## 1 Burundi 6.022 8.0 200 51 55 46.0
## 2 Ethiopia 51.070 11.0 130 50 53 45.0
## 3 Kenya 26.164 26.0 385 60 64 44.0
## 4 Madagascar 12.596 22.0 200 51 55 47.0
## 5 Malawi 9.605 15.0 200 48 51 52.0
## 6 Mauritius 1.082 41.0 2300 66 74 19.0
## 7 Mozambique 15.469 19.0 120 46 49 46.0
## 8 Rwanda 8.206 5.0 310 51 55 52.0
## 9 Somalia 7.235 36.0 170 56 55 46.0
## 10 Tanzania 27.791 32.0 260 50 55 50.0
## 11 Uganda 19.386 11.0 300 50 52 51.0
## 12 Zambia 8.745 49.0 380 55 59 48.0
## 13 Zimbabwe 11.033 25.0 660 60 64 41.0
## 14 Angola 8.902 29.0 950 43 47 46.0
## 15 Cameroon 12.658 40.0 1010 55 60 44.0
## 16 Central African Rep. 3.029 47.0 440 46 49 44.0
## 17 Chad 5.238 32.0 190 39 41 42.0
## 18 Congo 2.376 41.0 1070 52 56 43.0
## 19 Gabon 1.106 45.0 4400 51 56 28.0
## 20 Zaire 39.084 44.0 180 52 56 45.0
## 21 Algeria 26.666 51.0 2130 66 68 31.0
## 22 Egypt 56.386 44.0 720 58 62 33.0
## 23 Libya 44.850 70.0 6800 66 71 36.0
## 24 Morocco 26.708 50.0 1060 63 67 30.0
## 25 Sudan 28.305 22.0 450 53 54 44.0
## 26 Tunisia 8.445 49.0 1320 70 74 26.0
## 27 Botswana 1.300 25.0 2384 59 65 36.0
## 28 Lesotho 1.848 16.0 240 60 63 35.0
## 29 Namibia 1.574 33.0 1400 58 63 45.0
## 30 South Africa 41.688 60.0 2600 62 67 35.0
## 31 Benin 4.997 20.0 400 49 52 49.0
## 32 Burkina Faso 9.653 8.0 205 52 53 50.0
## 33 Ghana 16.185 33.0 400 53 56 46.0
## 34 Guinea 7.783 26.0 410 41 45 46.0
## 35 Liberia 2.462 46.0 440 54 59 45.0
## 36 Mali 8.641 25.0 265 43 47 51.0
## 37 Mauritania 2.059 34.0 520 44 50 49.0
## 38 Niger 8.052 21.0 300 42 45 58.0
## 39 Nigeria 88.500 35.0 230 48 50 46.0
## 40 Senegal 8.205 30.0 615 54 57 44.0
## 41 Sierra Leone 4.456 33.0 330 43 48 46.0
## 42 Togo 3.958 25.0 400 54 58 48.0
## 43 Cuba 10.846 72.0 1580 74 79 18.0
## 44 Dominican Republic 7.515 60.0 950 66 70 27.0
## 45 Haiti 6.431 29.0 440 53 55 43.0
## 46 Jamaica 2.506 52.0 1400 72 76 24.0
## 47 Trinidad & Tobago 1.285 64.0 3600 68 73 21.0
## 48 Costa Rica 3.187 50.0 1810 75 79 27.0
## 49 El Salvador 5.574 45.0 1010 68 75 33.0
## 50 Guatemala 9.784 39.0 1260 61 66 34.0
## 51 Honduras 4.949 40.0 960 64 68 38.0
## 52 Mexico 92.380 72.0 3200 69 76 29.0
## 53 Nicaragua 3.878 60.0 425 61 66 37.0
## 54 Panama 2.529 53.0 1150 73 77 26.0
## 55 Argentina 32.901 87.0 3100 67 74 20.0
## 56 Bolivia 7.323 51.0 690 59 64 34.0
## 57 Brazil 158.000 76.0 2540 62 68 26.0
## 58 Chile 13.528 84.0 2200 71 77 21.0
## 59 Colombia 34.296 65.4 1300 69 74 24.0
## 60 Equador 10.933 54.0 1070 67 72 28.0
## 61 Guyana 0.739 35.0 300 61 68 21.0
## 62 Paraguay 4.929 46.0 1460 71 74 33.0
## 63 Peru 22.767 70.0 920 63 67 28.0
## 64 Uruguay 3.121 86.0 2935 69 76 17.0
## 65 Venezuela 20.675 83.0 2590 71 78 28.0
## 66 Canada 27.351 77.0 19400 74 81 14.0
## 67 United States 256.561 76.0 22470 72 79 14.0
## 68 China 1169.619 27.0 360 69 72 22.0
## 69 Japan 124.460 77.0 19100 77 82 10.0
## 70 North Korea 22.227 60.0 1035 66 72 24.0
## 71 South Korea 44.149 74.0 6300 67 73 15.0
## 72 Mongolia 2.305 58.0 900 63 68 34.0
## 73 Cambodia 7.249 12.0 130 48 51 37.0
## 74 Indonesia 195.000 31.0 630 59 64 26.0
## 75 Laos 4.440 19.0 200 49 52 44.0
## 76 Malaysia 18.410 38.0 2670 66 71 30.0
## 77 Myanmar 42.642 25.0 530 57 61 29.0
## 78 Singapore 2.792 100.0 13900 73 78 18.0
## 79 Thailand 57.624 20.0 1630 67 71 20.0
## 80 Vietnam 68.964 20.0 230 63 67 29.0
## 81 Afghanistan 16.095 18.0 220 45 43 44.0
## 82 Bangladesh 119.000 24.0 200 55 54 36.0
## 83 Bhutan 1.660 95.0 199 50 48 40.0
## 84 India 886.362 28.0 380 57 58 30.0
## 85 Iran 61.183 57.0 1500 64 66 44.0
## 86 Nepal 20.086 8.0 165 51 51 38.0
## 87 Pakistan 121.644 32.0 380 56 57 43.0
## 88 Sri Lanka 17.631 26.0 410 69 74 21.0
## 89 Iraq 18.445 70.0 1950 62 64 45.0
## 90 Israel 4.748 89.0 12500 76 79 21.0
## 91 Jordan 3.557 68.0 1012 70 73 46.7
## 92 Kuwait 1.318 95.0 6200 72 76 32.0
## 93 Lebanon 3.439 84.0 1400 66 71 28.0
## 94 Oman 1.587 10.0 4852 65 69 NA
## 95 Saudi Arabia 16.900 78.0 5800 65 68 38.0
## 96 Syria 13.730 50.0 2300 65 67 44.0
## 97 Turkey 59.640 61.0 3400 68 72 28.0
## 98 United Arab Emirate 2.522 81.0 12100 70 74 20.0
## 99 Yemen 10.394 29.0 545 49 51 51.0
## 100 Bulgaria 8.868 67.0 5300 69 76 13.0
## 101 Hungary 10.333 62.0 5700 66 75 12.0
## 102 Poland 38.385 62.0 4300 68 76 14.0
## 103 Romania 23.169 55.0 3100 68 74 14.0
## 104 Denmark 5.163 86.0 17700 72 78 12.0
## 105 Finland 5.004 61.0 16200 72 80 12.0
## 106 Ireland 3.531 57.0 11200 72 78 15.0
## 107 Norway 4.294 75.0 17100 74 81 14.0
## 108 Sweden 8.602 85.0 17200 75 81 13.0
## 109 United Kingdom 57.798 90.0 15900 73 79 14.0
## 110 Albania 3.285 35.0 1300 72 79 23.0
## 111 Greece 10.064 63.0 7730 75 80 11.0
## 112 Italy 57.904 67.0 16700 74 81 11.0
## 113 Portugal 10.448 34.0 8400 71 78 12.0
## 114 Spain 39.118 79.0 12400 75 82 11.0
## 115 Austria 7.867 54.0 20895 74 81 12.0
## 116 Belgium 10.016 96.0 17300 73 80 10.0
## 117 France 57.287 74.0 18300 74 82 13.0
## 118 Netherlands 15.112 88.3 16600 75 81 13.0
## 119 Switzerland 6.828 60.0 21700 76 83 12.0
## 120 Australia 17.567 85.0 18054 74 80 15.0
## 121 New Zealand 3.347 76.0 14000 72 80 15.0
## 122 Papua New Guinea 4.006 15.0 800 55 56 34.0
## deathrat infmr fertrate
## 1 14 106.0 6.1
## 2 15 113.0 6.3
## 3 8 68.0 7.6
## 4 15 93.0 6.5
## 5 18 136.0 6.9
## 6 6 22.0 1.9
## 7 17 134.0 6.2
## 8 15 108.0 8.0
## 9 13 116.0 6.5
## 10 16 103.0 7.0
## 11 15 91.0 6.8
## 12 11 77.0 7.0
## 13 8 59.0 5.3
## 14 19 151.0 6.3
## 15 11 81.0 5.7
## 16 19 135.0 5.8
## 17 22 136.0 5.8
## 18 13 110.0 5.8
## 19 15 100.0 5.3
## 20 14 97.0 6.0
## 21 7 57.0 5.2
## 22 10 80.0 4.2
## 23 6 60.0 6.7
## 24 8 56.0 4.2
## 25 14 85.0 6.3
## 26 5 38.0 3.4
## 27 9 43.0 5.9
## 28 10 74.0 5.6
## 29 10 66.0 5.7
## 30 8 51.0 4.2
## 31 16 115.0 6.9
## 32 16 117.0 6.4
## 33 13 86.0 6.2
## 34 21 144.0 6.1
## 35 13 119.0 6.4
## 36 21 110.0 6.6
## 37 19 89.0 6.4
## 38 23 125.0 7.0
## 39 17 110.0 6.8
## 40 13 80.0 6.2
## 41 21 148.0 6.4
## 42 12 94.0 6.0
## 43 7 12.0 1.7
## 44 7 56.0 3.3
## 45 15 104.0 4.4
## 46 6 17.0 2.4
## 47 6 18.0 2.5
## 48 4 12.0 3.0
## 49 5 26.0 4.5
## 50 8 56.0 5.4
## 51 7 56.0 4.9
## 52 5 29.0 3.1
## 53 8 57.0 5.0
## 54 5 17.0 2.9
## 55 9 31.0 2.8
## 56 19 83.0 5.8
## 57 7 67.0 3.2
## 58 6 18.0 2.7
## 59 5 37.0 3.3
## 60 6 60.0 4.3
## 61 7 51.0 2.4
## 62 5 28.0 4.3
## 63 8 59.0 4.0
## 64 10 22.0 2.5
## 65 4 23.0 3.5
## 66 7 7.3 1.7
## 67 9 10.0 1.9
## 68 7 33.0 2.2
## 69 7 4.0 1.8
## 70 6 30.0 3.2
## 71 6 23.0 1.8
## 72 6 47.0 5.2
## 73 15 121.0 4.4
## 74 8 70.0 2.9
## 75 16 107.0 5.3
## 76 6 27.0 3.1
## 77 10 68.0 3.7
## 78 5 6.0 1.7
## 79 7 35.0 2.2
## 80 8 48.0 3.7
## 81 20 164.0 6.8
## 82 13 112.0 5.1
## 83 17 126.0 5.5
## 84 11 81.0 4.1
## 85 10 66.0 5.4
## 86 14 90.0 5.5
## 87 14 105.0 5.9
## 88 6 21.0 2.5
## 89 8 84.0 5.9
## 90 6 9.0 2.7
## 91 5 38.0 6.9
## 92 2 15.0 4.3
## 93 7 43.0 3.1
## 94 NA 40.0 7.1
## 95 7 69.0 7.1
## 96 7 45.0 6.3
## 97 6 54.0 3.2
## 98 3 23.0 4.3
## 99 16 118.0 5.7
## 100 12 13.0 1.8
## 101 14 14.0 1.8
## 102 9 14.0 2.1
## 103 10 22.0 2.0
## 104 11 7.0 1.5
## 105 10 6.0 1.7
## 106 9 8.0 2.4
## 107 11 7.1 1.7
## 108 11 6.0 1.7
## 109 11 8.0 1.8
## 110 5 27.0 2.7
## 111 9 10.0 1.7
## 112 10 8.0 1.5
## 113 10 10.0 1.7
## 114 8 6.0 1.7
## 115 11 8.0 1.5
## 116 10 8.0 NA
## 117 9 7.0 1.8
## 118 9 7.0 1.5
## 119 10 5.0 1.6
## 120 8 8.0 1.8
## 121 8 10.0 1.8
## 122 11 55.0 NA
summary(data2)
## country pop92 urban gdp
## Afghanistan: 1 Min. : 0.739 Min. : 5.00 Min. : 120
## Albania : 1 1st Qu.: 4.444 1st Qu.: 28.25 1st Qu.: 400
## Algeria : 1 Median : 9.900 Median : 48.00 Median : 1110
## Angola : 1 Mean : 40.749 Mean : 48.78 Mean : 4158
## Argentina : 1 3rd Qu.: 27.190 3rd Qu.: 69.50 3rd Qu.: 4375
## Australia : 1 Max. :1169.619 Max. :100.00 Max. :22470
## (Other) :116
## lifeexpm lifeexpf birthrat deathrat
## Min. :39.00 Min. :41.00 Min. :10.00 Min. : 2.00
## 1st Qu.:53.25 1st Qu.:56.00 1st Qu.:20.00 1st Qu.: 7.00
## Median :64.00 Median :68.00 Median :31.00 Median :10.00
## Mean :61.90 Mean :66.31 Mean :31.29 Mean :10.46
## 3rd Qu.:70.75 3rd Qu.:76.00 3rd Qu.:44.00 3rd Qu.:14.00
## Max. :77.00 Max. :83.00 Max. :58.00 Max. :23.00
## NA's :1 NA's :1
## infmr fertrate
## Min. : 4.00 Min. :1.500
## 1st Qu.: 18.00 1st Qu.:2.400
## Median : 55.50 Median :4.300
## Mean : 58.49 Mean :4.279
## 3rd Qu.: 92.50 3rd Qu.:6.025
## Max. :164.00 Max. :8.000
## NA's :2
library(PerformanceAnalytics)
## Warning: package 'PerformanceAnalytics' was built under R version 3.6.3
## Loading required package: xts
## Warning: package 'xts' was built under R version 3.6.1
## Loading required package: zoo
## Warning: package 'zoo' was built under R version 3.6.1
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
##
## Attaching package: 'PerformanceAnalytics'
## The following object is masked from 'package:graphics':
##
## legend
chart.Correlation(data2[,2:10], histogram=TRUE, pch=19)
f<-table(d$country,d$develop)
f
##
## Developing country Developed country
## Afghanistan 0 1
## Albania 1 0
## Algeria 0 1
## Angola 0 1
## Argentina 1 0
## Australia 0 1
## Austria 0 1
## Bangladesh 1 0
## Belgium 0 1
## Benin 0 1
## Bhutan 0 1
## Bolivia 0 1
## Botswana 0 1
## Brazil 0 1
## Bulgaria 1 0
## Burkina Faso 0 1
## Burundi 0 1
## Cambodia 0 1
## Cameroon 0 1
## Canada 0 1
## Central African Rep. 0 1
## Chad 0 1
## Chile 0 1
## China 0 1
## Colombia 0 1
## Congo 0 1
## Costa Rica 0 1
## Cuba 0 1
## Denmark 0 1
## Dominican Republic 0 1
## Egypt 0 1
## El Salvador 0 1
## Equador 0 1
## Ethiopia 0 1
## Finland 0 1
## France 0 1
## Gabon 0 1
## Ghana 0 1
## Greece 0 1
## Guatemala 0 1
## Guinea 0 1
## Guyana 0 1
## Haiti 0 1
## Honduras 0 1
## Hungary 0 1
## India 1 0
## Indonesia 0 1
## Iran 0 1
## Iraq 0 1
## Ireland 0 1
## Israel 1 0
## Italy 0 1
## Jamaica 0 1
## Japan 0 1
## Jordan 0 1
## Kenya 0 1
## Kuwait 0 1
## Laos 0 1
## Lebanon 0 1
## Lesotho 0 1
## Liberia 0 1
## Libya 0 1
## Madagascar 0 1
## Malawi 0 1
## Malaysia 0 1
## Mali 0 1
## Mauritania 0 1
## Mauritius 0 1
## Mexico 0 1
## Mongolia 1 0
## Morocco 0 1
## Mozambique 0 1
## Myanmar 0 1
## Namibia 1 0
## Nepal 0 1
## Netherlands 0 1
## New Zealand 0 1
## Nicaragua 0 1
## Niger 0 1
## Nigeria 0 1
## North Korea 0 1
## Norway 0 1
## Oman 1 0
## Pakistan 1 0
## Panama 0 1
## Papua New Guinea 0 1
## Paraguay 0 1
## Peru 0 1
## Poland 0 1
## Portugal 0 1
## Romania 1 0
## Rwanda 0 1
## Saudi Arabia 0 1
## Senegal 0 1
## Sierra Leone 0 1
## Singapore 0 1
## Somalia 0 1
## South Africa 1 0
## South Korea 0 1
## Spain 1 0
## Sri Lanka 0 1
## Sudan 0 1
## Sweden 1 0
## Switzerland 0 1
## Syria 0 1
## Tanzania 0 1
## Thailand 0 1
## Togo 0 1
## Trinidad & Tobago 0 1
## Tunisia 0 1
## Turkey 0 1
## Uganda 0 1
## United Arab Emirate 0 1
## United Kingdom 0 1
## United States 0 1
## Uruguay 0 1
## Venezuela 0 1
## Vietnam 0 1
## Yemen 0 1
## Zaire 0 1
## Zambia 0 1
## Zimbabwe 0 1
f<-data.frame(f)
f
## Var1 Var2 Freq
## 1 Afghanistan Developing country 0
## 2 Albania Developing country 1
## 3 Algeria Developing country 0
## 4 Angola Developing country 0
## 5 Argentina Developing country 1
## 6 Australia Developing country 0
## 7 Austria Developing country 0
## 8 Bangladesh Developing country 1
## 9 Belgium Developing country 0
## 10 Benin Developing country 0
## 11 Bhutan Developing country 0
## 12 Bolivia Developing country 0
## 13 Botswana Developing country 0
## 14 Brazil Developing country 0
## 15 Bulgaria Developing country 1
## 16 Burkina Faso Developing country 0
## 17 Burundi Developing country 0
## 18 Cambodia Developing country 0
## 19 Cameroon Developing country 0
## 20 Canada Developing country 0
## 21 Central African Rep. Developing country 0
## 22 Chad Developing country 0
## 23 Chile Developing country 0
## 24 China Developing country 0
## 25 Colombia Developing country 0
## 26 Congo Developing country 0
## 27 Costa Rica Developing country 0
## 28 Cuba Developing country 0
## 29 Denmark Developing country 0
## 30 Dominican Republic Developing country 0
## 31 Egypt Developing country 0
## 32 El Salvador Developing country 0
## 33 Equador Developing country 0
## 34 Ethiopia Developing country 0
## 35 Finland Developing country 0
## 36 France Developing country 0
## 37 Gabon Developing country 0
## 38 Ghana Developing country 0
## 39 Greece Developing country 0
## 40 Guatemala Developing country 0
## 41 Guinea Developing country 0
## 42 Guyana Developing country 0
## 43 Haiti Developing country 0
## 44 Honduras Developing country 0
## 45 Hungary Developing country 0
## 46 India Developing country 1
## 47 Indonesia Developing country 0
## 48 Iran Developing country 0
## 49 Iraq Developing country 0
## 50 Ireland Developing country 0
## 51 Israel Developing country 1
## 52 Italy Developing country 0
## 53 Jamaica Developing country 0
## 54 Japan Developing country 0
## 55 Jordan Developing country 0
## 56 Kenya Developing country 0
## 57 Kuwait Developing country 0
## 58 Laos Developing country 0
## 59 Lebanon Developing country 0
## 60 Lesotho Developing country 0
## 61 Liberia Developing country 0
## 62 Libya Developing country 0
## 63 Madagascar Developing country 0
## 64 Malawi Developing country 0
## 65 Malaysia Developing country 0
## 66 Mali Developing country 0
## 67 Mauritania Developing country 0
## 68 Mauritius Developing country 0
## 69 Mexico Developing country 0
## 70 Mongolia Developing country 1
## 71 Morocco Developing country 0
## 72 Mozambique Developing country 0
## 73 Myanmar Developing country 0
## 74 Namibia Developing country 1
## 75 Nepal Developing country 0
## 76 Netherlands Developing country 0
## 77 New Zealand Developing country 0
## 78 Nicaragua Developing country 0
## 79 Niger Developing country 0
## 80 Nigeria Developing country 0
## 81 North Korea Developing country 0
## 82 Norway Developing country 0
## 83 Oman Developing country 1
## 84 Pakistan Developing country 1
## 85 Panama Developing country 0
## 86 Papua New Guinea Developing country 0
## 87 Paraguay Developing country 0
## 88 Peru Developing country 0
## 89 Poland Developing country 0
## 90 Portugal Developing country 0
## 91 Romania Developing country 1
## 92 Rwanda Developing country 0
## 93 Saudi Arabia Developing country 0
## 94 Senegal Developing country 0
## 95 Sierra Leone Developing country 0
## 96 Singapore Developing country 0
## 97 Somalia Developing country 0
## 98 South Africa Developing country 1
## 99 South Korea Developing country 0
## 100 Spain Developing country 1
## 101 Sri Lanka Developing country 0
## 102 Sudan Developing country 0
## 103 Sweden Developing country 1
## 104 Switzerland Developing country 0
## 105 Syria Developing country 0
## 106 Tanzania Developing country 0
## 107 Thailand Developing country 0
## 108 Togo Developing country 0
## 109 Trinidad & Tobago Developing country 0
## 110 Tunisia Developing country 0
## 111 Turkey Developing country 0
## 112 Uganda Developing country 0
## 113 United Arab Emirate Developing country 0
## 114 United Kingdom Developing country 0
## 115 United States Developing country 0
## 116 Uruguay Developing country 0
## 117 Venezuela Developing country 0
## 118 Vietnam Developing country 0
## 119 Yemen Developing country 0
## 120 Zaire Developing country 0
## 121 Zambia Developing country 0
## 122 Zimbabwe Developing country 0
## 123 Afghanistan Developed country 1
## 124 Albania Developed country 0
## 125 Algeria Developed country 1
## 126 Angola Developed country 1
## 127 Argentina Developed country 0
## 128 Australia Developed country 1
## 129 Austria Developed country 1
## 130 Bangladesh Developed country 0
## 131 Belgium Developed country 1
## 132 Benin Developed country 1
## 133 Bhutan Developed country 1
## 134 Bolivia Developed country 1
## 135 Botswana Developed country 1
## 136 Brazil Developed country 1
## 137 Bulgaria Developed country 0
## 138 Burkina Faso Developed country 1
## 139 Burundi Developed country 1
## 140 Cambodia Developed country 1
## 141 Cameroon Developed country 1
## 142 Canada Developed country 1
## 143 Central African Rep. Developed country 1
## 144 Chad Developed country 1
## 145 Chile Developed country 1
## 146 China Developed country 1
## 147 Colombia Developed country 1
## 148 Congo Developed country 1
## 149 Costa Rica Developed country 1
## 150 Cuba Developed country 1
## 151 Denmark Developed country 1
## 152 Dominican Republic Developed country 1
## 153 Egypt Developed country 1
## 154 El Salvador Developed country 1
## 155 Equador Developed country 1
## 156 Ethiopia Developed country 1
## 157 Finland Developed country 1
## 158 France Developed country 1
## 159 Gabon Developed country 1
## 160 Ghana Developed country 1
## 161 Greece Developed country 1
## 162 Guatemala Developed country 1
## 163 Guinea Developed country 1
## 164 Guyana Developed country 1
## 165 Haiti Developed country 1
## 166 Honduras Developed country 1
## 167 Hungary Developed country 1
## 168 India Developed country 0
## 169 Indonesia Developed country 1
## 170 Iran Developed country 1
## 171 Iraq Developed country 1
## 172 Ireland Developed country 1
## 173 Israel Developed country 0
## 174 Italy Developed country 1
## 175 Jamaica Developed country 1
## 176 Japan Developed country 1
## 177 Jordan Developed country 1
## 178 Kenya Developed country 1
## 179 Kuwait Developed country 1
## 180 Laos Developed country 1
## 181 Lebanon Developed country 1
## 182 Lesotho Developed country 1
## 183 Liberia Developed country 1
## 184 Libya Developed country 1
## 185 Madagascar Developed country 1
## 186 Malawi Developed country 1
## 187 Malaysia Developed country 1
## 188 Mali Developed country 1
## 189 Mauritania Developed country 1
## 190 Mauritius Developed country 1
## 191 Mexico Developed country 1
## 192 Mongolia Developed country 0
## 193 Morocco Developed country 1
## 194 Mozambique Developed country 1
## 195 Myanmar Developed country 1
## 196 Namibia Developed country 0
## 197 Nepal Developed country 1
## 198 Netherlands Developed country 1
## 199 New Zealand Developed country 1
## 200 Nicaragua Developed country 1
## 201 Niger Developed country 1
## 202 Nigeria Developed country 1
## 203 North Korea Developed country 1
## 204 Norway Developed country 1
## 205 Oman Developed country 0
## 206 Pakistan Developed country 0
## 207 Panama Developed country 1
## 208 Papua New Guinea Developed country 1
## 209 Paraguay Developed country 1
## 210 Peru Developed country 1
## 211 Poland Developed country 1
## 212 Portugal Developed country 1
## 213 Romania Developed country 0
## 214 Rwanda Developed country 1
## 215 Saudi Arabia Developed country 1
## 216 Senegal Developed country 1
## 217 Sierra Leone Developed country 1
## 218 Singapore Developed country 1
## 219 Somalia Developed country 1
## 220 South Africa Developed country 0
## 221 South Korea Developed country 1
## 222 Spain Developed country 0
## 223 Sri Lanka Developed country 1
## 224 Sudan Developed country 1
## 225 Sweden Developed country 0
## 226 Switzerland Developed country 1
## 227 Syria Developed country 1
## 228 Tanzania Developed country 1
## 229 Thailand Developed country 1
## 230 Togo Developed country 1
## 231 Trinidad & Tobago Developed country 1
## 232 Tunisia Developed country 1
## 233 Turkey Developed country 1
## 234 Uganda Developed country 1
## 235 United Arab Emirate Developed country 1
## 236 United Kingdom Developed country 1
## 237 United States Developed country 1
## 238 Uruguay Developed country 1
## 239 Venezuela Developed country 1
## 240 Vietnam Developed country 1
## 241 Yemen Developed country 1
## 242 Zaire Developed country 1
## 243 Zambia Developed country 1
## 244 Zimbabwe Developed country 1
summary(f)
## Var1 Var2 Freq
## Afghanistan: 2 Developing country:122 Min. :0.0
## Albania : 2 Developed country :122 1st Qu.:0.0
## Algeria : 2 Median :0.5
## Angola : 2 Mean :0.5
## Argentina : 2 3rd Qu.:1.0
## Australia : 2 Max. :1.0
## (Other) :232
library(ggplot2)
library(plotly)
## Warning: package 'plotly' was built under R version 3.6.3
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
#Bar diagram between Country Vs Popn and Country Type
p<-ggplot(data=d, aes(x=country,
y=pop92,
fill = develop
))
p<-p + geom_bar(stat = "identity")
ggplotly(p)
#bar dagram of Region Population & Developing country
Q<-ggplot(data=d, aes(x=region,
y=pop92,
fill = develop
))
Q<-Q + geom_bar(stat = "identity")
ggplotly(Q)
#Bar diagran about country population and region
r<-ggplot(data=d, aes(x=country,
y=pop92,
fill = region
))
r<-r + geom_bar(stat = "identity")
ggplotly(r)
# bar diagram of Country, urban & Develop
a<-ggplot(data=d, aes(x=country,
y=urban,
fill = develop
))
a<-a + geom_bar(stat = "identity")
ggplotly(a)
#bar diagram about Regiion urban & Develop
b<-ggplot(data=d, aes(x=region,
y=urban,
fill = develop
))
b<-b + geom_bar(stat = "identity")
ggplotly(b)
#Bar diagram of Country , urban and region
c<-ggplot(data=d, aes(x=country,
y=urban,
fill = region
))
c<-c + geom_bar(stat = "identity")
ggplotly(c)
#bar diagram about country gdb and Develop
e<-ggplot(data=d, aes(x=country,
y=gdp,
fill = develop
))
e<-e + geom_bar(stat = "identity")
ggplotly(e)
#bar diagram about country, gdb and Region
f<-ggplot(data=d, aes(x=country,
y=gdp,
fill = region
))
f<-f + geom_bar(stat = "identity")
ggplotly(f)
#bar diagram about Region, gdb and Deveop
g<-ggplot(data=d, aes(x=region,
y=gdp,
fill = develop
))
g<-g + geom_bar(stat = "identity")
ggplotly(g)
#Study about country,life Expectency, Region & Develop
#bar diagram about country, lifeexpm and develop
h<-ggplot(data=d, aes(x=country,
y=lifeexpm,
fill = develop
))
h<-h + geom_bar(stat = "identity")
ggplotly(h)
#bar diagram about country, lifeexpm and Region
i<-ggplot(data=d, aes(x=country,
y=lifeexpm,
fill = region
))
i<-i + geom_bar(stat = "identity")
ggplotly(i)
#bar diagram about Region, Lifeexpm and Develop
j<-ggplot(data=d, aes(x=region,
y=lifeexpm,
fill = develop
))
j<-j + geom_bar(stat = "identity")
ggplotly(j)
#Country birthrate and region
k<-ggplot(data=d, aes(x=country,
y=birthrat,
fill = develop
))
k<-k + geom_bar(stat = "identity")
ggplotly(k)
## Warning: Removed 1 rows containing missing values (position_stack).
#Country Death rate and Region
l<-ggplot(data=d, aes(x=country,
y=deathrat,
fill = develop
))
l<-l + geom_bar(stat = "identity")
ggplotly(l)
## Warning: Removed 1 rows containing missing values (position_stack).
#Country Infant ortality & Develop
m<-ggplot(data=d, aes(x=country,
y=infmr,
fill = develop
))
m<-m + geom_bar(stat = "identity")
ggplotly(m)
#Country Fertility rate & Develop
n<-ggplot(data=d, aes(x=country,
y=fertrate,
fill = develop
))
n<-n + geom_bar(stat = "identity")
ggplotly(n)
## Warning: Removed 2 rows containing missing values (position_stack).
#Bar diagram about Country Birth rate Death rate & Fertillity
o<-ggplot(data=d, aes(x=birthrat,
y=deathrat,
fill = country
))
o<-o + geom_bar(stat = "identity")
ggplotly(o)
## Warning: Removed 1 rows containing missing values (position_stack).
reg<-lm(formula = gdp~pop92+urban+lifeexpm+lifeexpf+birthrat+deathrat+infmr+fertrate,data = d)
reg
##
## Call:
## lm(formula = gdp ~ pop92 + urban + lifeexpm + lifeexpf + birthrat +
## deathrat + infmr + fertrate, data = d)
##
## Coefficients:
## (Intercept) pop92 urban lifeexpm lifeexpf birthrat
## -4.054e+04 1.841e-01 4.686e+01 3.488e+02 1.972e+02 -1.933e+02
## deathrat infmr fertrate
## 1.007e+03 -1.428e+01 9.519e+02
summary(reg)
##
## Call:
## lm(formula = gdp ~ pop92 + urban + lifeexpm + lifeexpf + birthrat +
## deathrat + infmr + fertrate, data = d)
##
## Residuals:
## Min 1Q Median 3Q Max
## -11265.5 -1517.9 232.7 1728.9 10679.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4.054e+04 1.203e+04 -3.371 0.00103 **
## pop92 1.841e-01 2.523e+00 0.073 0.94195
## urban 4.686e+01 1.963e+01 2.387 0.01871 *
## lifeexpm 3.488e+02 2.304e+02 1.514 0.13281
## lifeexpf 1.972e+02 2.392e+02 0.825 0.41135
## birthrat -1.933e+02 9.528e+01 -2.029 0.04487 *
## deathrat 1.007e+03 1.391e+02 7.242 6.4e-11 ***
## infmr -1.428e+01 3.131e+01 -0.456 0.64919
## fertrate 9.519e+02 5.706e+02 1.668 0.09814 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3489 on 110 degrees of freedom
## (3 observations deleted due to missingness)
## Multiple R-squared: 0.6913, Adjusted R-squared: 0.6688
## F-statistic: 30.78 on 8 and 110 DF, p-value: < 2.2e-16
From the above ANNOVA table we find that, Urbanization birthrate are Singnificant, on the other hand Deathrate are Highly Significant of the dependent variable GDP. Adjusted R squared is 0.6688, that means the total 67 percent can be explained of the independent variable GDP.
#Regession Line of GDP, Birthrate among Developed & Developing Countries
d1<-ggplot(
data = d,
aes(x = gdp, y = birthrat,fil=develop,colour=develop)) +
geom_point() +
geom_smooth(method = "lm") +
ggtitle("gdp vs. birthrat & develop") +
xlab("gdp") +
ylab("birthrat")
ggplotly(d1)
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
#Regression line of GDP, Deathrate among Developed & Developing Countries
d2<-ggplot(
data = d,
aes(x = gdp, y = deathrat,fil=develop,colour=develop)) +
geom_point() +
geom_smooth(method = "lm") +
ggtitle("gdp vs. deathrat & develop") +
xlab("gdp") +
ylab("deathrat")
ggplotly(d2)
## Warning: Removed 1 rows containing non-finite values (stat_smooth).
#Regression ine of GDP, Urbanaization among Developed and Developing Countries
d3<-ggplot(
data = d,
aes(x = gdp, y = urban,fil=develop,colour=develop)) +
geom_point() +
geom_smooth(method = "lm") +
ggtitle("gdp vs. urban & develop") +
xlab("gdp") +
ylab("urban")
ggplotly(d3)
library(rpart)
library(rpart.plot)
## Warning: package 'rpart.plot' was built under R version 3.6.1
latlontree1 = rpart(pop92~gdp+lifeexpm,data=d)
latlontree2 = rpart(pop92~gdp+birthrat,data=d)
latlontree3 = rpart(pop92~gdp+deathrat,data=d)
# Plot the tree using prp command defined in rpart.plot package
prp(latlontree1)
prp(latlontree2)
prp(latlontree3)
tree1 = rpart(pop92~gdp+urban+lifeexpm,data=d)
tree2 = rpart(pop92~gdp+birthrat,data=d)
tree3 = rpart(pop92~gdp+deathrat,data=d)
rpart.plot(tree1)
rpart.plot(tree2)
rpart.plot(tree3)
#Getting Region Developed
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 3.6.1
## -- Attaching packages ------------------------------------------------------------------------ tidyverse 1.2.1 --
## v tibble 2.1.3 v purrr 0.3.3
## v tidyr 1.0.0 v dplyr 0.8.3
## v readr 1.3.1 v stringr 1.4.0
## v tibble 2.1.3 v forcats 0.4.0
## Warning: package 'tibble' was built under R version 3.6.1
## Warning: package 'tidyr' was built under R version 3.6.1
## Warning: package 'readr' was built under R version 3.6.1
## Warning: package 'purrr' was built under R version 3.6.1
## Warning: package 'dplyr' was built under R version 3.6.1
## Warning: package 'stringr' was built under R version 3.6.1
## Warning: package 'forcats' was built under R version 3.6.1
## -- Conflicts --------------------------------------------------------------------------- tidyverse_conflicts() --
## x dplyr::filter() masks plotly::filter(), stats::filter()
## x dplyr::first() masks xts::first()
## x dplyr::lag() masks stats::lag()
## x dplyr::last() masks xts::last()
library(dplyr)
library(tidyr)
library(PerformanceAnalytics)
table<-d %>%
select(country = country, gdp, develop,region,pop92,birthrat) %>%
group_by(country, develop,region,pop92,birthrat) %>%
summarise(total_gdp = sum(gdp))
data.frame(table)
## country develop region pop92 birthrat
## 1 Afghanistan Developed country Western Asia 16.095 44.0
## 2 Albania Developing country Western Europe 3.285 23.0
## 3 Algeria Developed country Southern Africa 26.666 31.0
## 4 Angola Developed country Northern Africa 8.902 46.0
## 5 Argentina Developing country North America 32.901 20.0
## 6 Australia Developed country USSR 17.567 15.0
## 7 Austria Developed country Oceania 7.867 12.0
## 8 Bangladesh Developing country Western Asia 119.000 36.0
## 9 Belgium Developed country Oceania 10.016 10.0
## 10 Benin Developed country Caribbean 4.997 49.0
## 11 Bhutan Developed country Western Asia 1.660 40.0
## 12 Bolivia Developed country North America 7.323 34.0
## 13 Botswana Developed country Western Africa 1.300 36.0
## 14 Brazil Developed country North America 158.000 26.0
## 15 Bulgaria Developing country Northern Europe 8.868 13.0
## 16 Burkina Faso Developed country Caribbean 9.653 50.0
## 17 Burundi Developed country Middle Africa 6.022 46.0
## 18 Cambodia Developed country Southern Asia 7.249 37.0
## 19 Cameroon Developed country Northern Africa 12.658 44.0
## 20 Canada Developed country Eastern Asia 27.351 14.0
## 21 Central African Rep. Developed country Northern Africa 3.029 44.0
## 22 Chad Developed country Northern Africa 5.238 42.0
## 23 Chile Developed country North America 13.528 21.0
## 24 China Developed country Southeast Asia 1169.619 22.0
## 25 Colombia Developed country North America 34.296 24.0
## 26 Congo Developed country Northern Africa 2.376 43.0
## 27 Costa Rica Developed country South America 3.187 27.0
## 28 Cuba Developed country Central America 10.846 18.0
## 29 Denmark Developed country Southern Europe 5.163 12.0
## 30 Dominican Republic Developed country Central America 7.515 27.0
## 31 Egypt Developed country Southern Africa 56.386 33.0
## 32 El Salvador Developed country South America 5.574 33.0
## 33 Equador Developed country North America 10.933 28.0
## 34 Ethiopia Developed country Middle Africa 51.070 45.0
## 35 Finland Developed country Southern Europe 5.004 12.0
## 36 France Developed country Oceania 57.287 13.0
## 37 Gabon Developed country Northern Africa 1.106 28.0
## 38 Ghana Developed country Caribbean 16.185 46.0
## 39 Greece Developed country Western Europe 10.064 11.0
## 40 Guatemala Developed country South America 9.784 34.0
## 41 Guinea Developed country Caribbean 7.783 46.0
## 42 Guyana Developed country North America 0.739 21.0
## 43 Haiti Developed country Central America 6.431 43.0
## 44 Honduras Developed country South America 4.949 38.0
## 45 Hungary Developed country Northern Europe 10.333 12.0
## 46 India Developing country Western Asia 886.362 30.0
## 47 Indonesia Developed country Southern Asia 195.000 26.0
## 48 Iran Developed country Western Asia 61.183 44.0
## 49 Iraq Developed country Eastern Europe 18.445 45.0
## 50 Ireland Developed country Southern Europe 3.531 15.0
## 51 Israel Developing country Eastern Europe 4.748 21.0
## 52 Italy Developed country Western Europe 57.904 11.0
## 53 Jamaica Developed country Central America 2.506 24.0
## 54 Japan Developed country Southeast Asia 124.460 10.0
## 55 Jordan Developed country Eastern Europe 3.557 46.7
## 56 Kenya Developed country Middle Africa 26.164 44.0
## 57 Kuwait Developed country Eastern Europe 1.318 32.0
## 58 Laos Developed country Southern Asia 4.440 44.0
## 59 Lebanon Developed country Eastern Europe 3.439 28.0
## 60 Lesotho Developed country Western Africa 1.848 35.0
## 61 Liberia Developed country Caribbean 2.462 45.0
## 62 Libya Developed country Southern Africa 44.850 36.0
## 63 Madagascar Developed country Middle Africa 12.596 47.0
## 64 Malawi Developed country Middle Africa 9.605 52.0
## 65 Malaysia Developed country Southern Asia 18.410 30.0
## 66 Mali Developed country Caribbean 8.641 51.0
## 67 Mauritania Developed country Caribbean 2.059 49.0
## 68 Mauritius Developed country Middle Africa 1.082 19.0
## 69 Mexico Developed country South America 92.380 29.0
## 70 Mongolia Developing country Southeast Asia 2.305 34.0
## 71 Morocco Developed country Southern Africa 26.708 30.0
## 72 Mozambique Developed country Middle Africa 15.469 46.0
## 73 Myanmar Developed country Southern Asia 42.642 29.0
## 74 Namibia Developing country Western Africa 1.574 45.0
## 75 Nepal Developed country Western Asia 20.086 38.0
## 76 Netherlands Developed country Oceania 15.112 13.0
## 77 New Zealand Developed country USSR 3.347 15.0
## 78 Nicaragua Developed country South America 3.878 37.0
## 79 Niger Developed country Caribbean 8.052 58.0
## 80 Nigeria Developed country Caribbean 88.500 46.0
## 81 North Korea Developed country Southeast Asia 22.227 24.0
## 82 Norway Developed country Southern Europe 4.294 14.0
## 83 Oman Developing country Eastern Europe 1.587 NA
## 84 Pakistan Developing country Western Asia 121.644 43.0
## 85 Panama Developed country South America 2.529 26.0
## 86 Papua New Guinea Developed country USSR 4.006 34.0
## 87 Paraguay Developed country North America 4.929 33.0
## 88 Peru Developed country North America 22.767 28.0
## 89 Poland Developed country Northern Europe 38.385 14.0
## 90 Portugal Developed country Western Europe 10.448 12.0
## 91 Romania Developing country Northern Europe 23.169 14.0
## 92 Rwanda Developed country Middle Africa 8.206 52.0
## 93 Saudi Arabia Developed country Eastern Europe 16.900 38.0
## 94 Senegal Developed country Caribbean 8.205 44.0
## 95 Sierra Leone Developed country Caribbean 4.456 46.0
## 96 Singapore Developed country Southern Asia 2.792 18.0
## 97 Somalia Developed country Middle Africa 7.235 46.0
## 98 South Africa Developing country Western Africa 41.688 35.0
## 99 South Korea Developed country Southeast Asia 44.149 15.0
## 100 Spain Developing country Western Europe 39.118 11.0
## 101 Sri Lanka Developed country Western Asia 17.631 21.0
## 102 Sudan Developed country Southern Africa 28.305 44.0
## 103 Sweden Developing country Southern Europe 8.602 13.0
## 104 Switzerland Developed country Oceania 6.828 12.0
## 105 Syria Developed country Eastern Europe 13.730 44.0
## 106 Tanzania Developed country Middle Africa 27.791 50.0
## 107 Thailand Developed country Southern Asia 57.624 20.0
## 108 Togo Developed country Caribbean 3.958 48.0
## 109 Trinidad & Tobago Developed country Central America 1.285 21.0
## 110 Tunisia Developed country Southern Africa 8.445 26.0
## 111 Turkey Developed country Eastern Europe 59.640 28.0
## 112 Uganda Developed country Eastern Africa 19.386 51.0
## 113 United Arab Emirate Developed country Eastern Europe 2.522 20.0
## 114 United Kingdom Developed country Southern Europe 57.798 14.0
## 115 United States Developed country Eastern Asia 256.561 14.0
## 116 Uruguay Developed country North America 3.121 17.0
## 117 Venezuela Developed country North America 20.675 28.0
## 118 Vietnam Developed country Southern Asia 68.964 29.0
## 119 Yemen Developed country Eastern Europe 10.394 51.0
## 120 Zaire Developed country Northern Africa 39.084 45.0
## 121 Zambia Developed country Middle Africa 8.745 48.0
## 122 Zimbabwe Developed country Middle Africa 11.033 41.0
## total_gdp
## 1 220
## 2 1300
## 3 2130
## 4 950
## 5 3100
## 6 18054
## 7 20895
## 8 200
## 9 17300
## 10 400
## 11 199
## 12 690
## 13 2384
## 14 2540
## 15 5300
## 16 205
## 17 200
## 18 130
## 19 1010
## 20 19400
## 21 440
## 22 190
## 23 2200
## 24 360
## 25 1300
## 26 1070
## 27 1810
## 28 1580
## 29 17700
## 30 950
## 31 720
## 32 1010
## 33 1070
## 34 130
## 35 16200
## 36 18300
## 37 4400
## 38 400
## 39 7730
## 40 1260
## 41 410
## 42 300
## 43 440
## 44 960
## 45 5700
## 46 380
## 47 630
## 48 1500
## 49 1950
## 50 11200
## 51 12500
## 52 16700
## 53 1400
## 54 19100
## 55 1012
## 56 385
## 57 6200
## 58 200
## 59 1400
## 60 240
## 61 440
## 62 6800
## 63 200
## 64 200
## 65 2670
## 66 265
## 67 520
## 68 2300
## 69 3200
## 70 900
## 71 1060
## 72 120
## 73 530
## 74 1400
## 75 165
## 76 16600
## 77 14000
## 78 425
## 79 300
## 80 230
## 81 1035
## 82 17100
## 83 4852
## 84 380
## 85 1150
## 86 800
## 87 1460
## 88 920
## 89 4300
## 90 8400
## 91 3100
## 92 310
## 93 5800
## 94 615
## 95 330
## 96 13900
## 97 170
## 98 2600
## 99 6300
## 100 12400
## 101 410
## 102 450
## 103 17200
## 104 21700
## 105 2300
## 106 260
## 107 1630
## 108 400
## 109 3600
## 110 1320
## 111 3400
## 112 300
## 113 12100
## 114 15900
## 115 22470
## 116 2935
## 117 2590
## 118 230
## 119 545
## 120 180
## 121 380
## 122 660
#Western Asia Observation
w<-d%>%filter(country==country, region=="Western Asia")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(w)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr fertrate
## 1 Afghanistan 16.095 18 45 43 44 20 164 6.8
## 2 Bangladesh 119.000 24 55 54 36 13 112 5.1
## 3 Bhutan 1.660 95 50 48 40 17 126 5.5
## 4 India 886.362 28 57 58 30 11 81 4.1
## 5 Iran 61.183 57 64 66 44 10 66 5.4
## 6 Nepal 20.086 8 51 51 38 14 90 5.5
## 7 Pakistan 121.644 32 56 57 43 14 105 5.9
## 8 Sri Lanka 17.631 26 69 74 21 6 21 2.5
## develop gdp
## 1 Developed country 220
## 2 Developing country 200
## 3 Developed country 199
## 4 Developing country 380
## 5 Developed country 1500
## 6 Developed country 165
## 7 Developing country 380
## 8 Developed country 410
summary(w)
## country pop92 urban lifeexpm
## Afghanistan:1 Min. : 1.66 Min. : 8.00 Min. :45.00
## Bangladesh :1 1st Qu.: 17.25 1st Qu.:22.50 1st Qu.:50.75
## Bhutan :1 Median : 40.63 Median :27.00 Median :55.50
## India :1 Mean :155.46 Mean :36.00 Mean :55.88
## Iran :1 3rd Qu.:119.66 3rd Qu.:38.25 3rd Qu.:58.75
## Nepal :1 Max. :886.36 Max. :95.00 Max. :69.00
## (Other) :2
## lifeexpf birthrat deathrat infmr
## Min. :43.00 Min. :21.00 Min. : 6.00 Min. : 21.00
## 1st Qu.:50.25 1st Qu.:34.50 1st Qu.:10.75 1st Qu.: 77.25
## Median :55.50 Median :39.00 Median :13.50 Median : 97.50
## Mean :56.38 Mean :37.00 Mean :13.12 Mean : 95.62
## 3rd Qu.:60.00 3rd Qu.:43.25 3rd Qu.:14.75 3rd Qu.:115.50
## Max. :74.00 Max. :44.00 Max. :20.00 Max. :164.00
##
## fertrate develop gdp
## Min. :2.50 Developing country:3 Min. : 165.0
## 1st Qu.:4.85 Developed country :5 1st Qu.: 199.8
## Median :5.45 Median : 300.0
## Mean :5.10 Mean : 431.8
## 3rd Qu.:5.60 3rd Qu.: 387.5
## Max. :6.80 Max. :1500.0
##
#Different Histogram of Westen Asia
library(PerformanceAnalytics)
chart.Correlation(w[,2:9,11], histogram=TRUE, pch=19)
#Western Europe Observation
we<-d%>%filter(country==country, region=="Western Europe")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(we)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr fertrate
## 1 Albania 3.285 35 72 79 23 5 27 2.7
## 2 Greece 10.064 63 75 80 11 9 10 1.7
## 3 Italy 57.904 67 74 81 11 10 8 1.5
## 4 Portugal 10.448 34 71 78 12 10 10 1.7
## 5 Spain 39.118 79 75 82 11 8 6 1.7
## develop gdp
## 1 Developing country 1300
## 2 Developed country 7730
## 3 Developed country 16700
## 4 Developed country 8400
## 5 Developing country 12400
summary(we)
## country pop92 urban lifeexpm lifeexpf
## Albania :1 Min. : 3.285 Min. :34.0 Min. :71.0 Min. :78
## Greece :1 1st Qu.:10.064 1st Qu.:35.0 1st Qu.:72.0 1st Qu.:79
## Italy :1 Median :10.448 Median :63.0 Median :74.0 Median :80
## Portugal :1 Mean :24.164 Mean :55.6 Mean :73.4 Mean :80
## Spain :1 3rd Qu.:39.118 3rd Qu.:67.0 3rd Qu.:75.0 3rd Qu.:81
## Afghanistan:0 Max. :57.904 Max. :79.0 Max. :75.0 Max. :82
## (Other) :0
## birthrat deathrat infmr fertrate
## Min. :11.0 Min. : 5.0 Min. : 6.0 Min. :1.50
## 1st Qu.:11.0 1st Qu.: 8.0 1st Qu.: 8.0 1st Qu.:1.70
## Median :11.0 Median : 9.0 Median :10.0 Median :1.70
## Mean :13.6 Mean : 8.4 Mean :12.2 Mean :1.86
## 3rd Qu.:12.0 3rd Qu.:10.0 3rd Qu.:10.0 3rd Qu.:1.70
## Max. :23.0 Max. :10.0 Max. :27.0 Max. :2.70
##
## develop gdp
## Developing country:2 Min. : 1300
## Developed country :3 1st Qu.: 7730
## Median : 8400
## Mean : 9306
## 3rd Qu.:12400
## Max. :16700
##
#Different Histogram
chart.Correlation(we[,2:9,11], histogram=TRUE, pch=19)
#Southern Africa Observation
Sa<-d%>%filter(country==country, region=="Southern Africa")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Sa)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr fertrate
## 1 Algeria 26.666 51 66 68 31 7 57 5.2
## 2 Egypt 56.386 44 58 62 33 10 80 4.2
## 3 Libya 44.850 70 66 71 36 6 60 6.7
## 4 Morocco 26.708 50 63 67 30 8 56 4.2
## 5 Sudan 28.305 22 53 54 44 14 85 6.3
## 6 Tunisia 8.445 49 70 74 26 5 38 3.4
## develop gdp
## 1 Developed country 2130
## 2 Developed country 720
## 3 Developed country 6800
## 4 Developed country 1060
## 5 Developed country 450
## 6 Developed country 1320
summary(Sa)
## country pop92 urban lifeexpm lifeexpf
## Algeria:1 Min. : 8.445 Min. :22.00 Min. :53.00 Min. :54.00
## Egypt :1 1st Qu.:26.677 1st Qu.:45.25 1st Qu.:59.25 1st Qu.:63.25
## Libya :1 Median :27.506 Median :49.50 Median :64.50 Median :67.50
## Morocco:1 Mean :31.893 Mean :47.67 Mean :62.67 Mean :66.00
## Sudan :1 3rd Qu.:40.714 3rd Qu.:50.75 3rd Qu.:66.00 3rd Qu.:70.25
## Tunisia:1 Max. :56.386 Max. :70.00 Max. :70.00 Max. :74.00
## (Other):0
## birthrat deathrat infmr fertrate
## Min. :26.00 Min. : 5.000 Min. :38.00 Min. :3.400
## 1st Qu.:30.25 1st Qu.: 6.250 1st Qu.:56.25 1st Qu.:4.200
## Median :32.00 Median : 7.500 Median :58.50 Median :4.700
## Mean :33.33 Mean : 8.333 Mean :62.67 Mean :5.000
## 3rd Qu.:35.25 3rd Qu.: 9.500 3rd Qu.:75.00 3rd Qu.:6.025
## Max. :44.00 Max. :14.000 Max. :85.00 Max. :6.700
##
## develop gdp
## Developing country:0 Min. : 450
## Developed country :6 1st Qu.: 805
## Median :1190
## Mean :2080
## 3rd Qu.:1928
## Max. :6800
##
#Different Histogram
chart.Correlation(Sa[,2:9,11], histogram=TRUE, pch=19)
#Northern Africa observation
Na<-d%>%filter(country==country, region=="Northern Africa")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Na)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr
## 1 Angola 8.902 29 43 47 46 19 151
## 2 Cameroon 12.658 40 55 60 44 11 81
## 3 Central African Rep. 3.029 47 46 49 44 19 135
## 4 Chad 5.238 32 39 41 42 22 136
## 5 Congo 2.376 41 52 56 43 13 110
## 6 Gabon 1.106 45 51 56 28 15 100
## 7 Zaire 39.084 44 52 56 45 14 97
## fertrate develop gdp
## 1 6.3 Developed country 950
## 2 5.7 Developed country 1010
## 3 5.8 Developed country 440
## 4 5.8 Developed country 190
## 5 5.8 Developed country 1070
## 6 5.3 Developed country 4400
## 7 6.0 Developed country 180
summary(Na)
## country pop92 urban lifeexpm
## Angola :1 Min. : 1.106 Min. :29.00 Min. :39.00
## Cameroon :1 1st Qu.: 2.703 1st Qu.:36.00 1st Qu.:44.50
## Central African Rep.:1 Median : 5.238 Median :41.00 Median :51.00
## Chad :1 Mean :10.342 Mean :39.71 Mean :48.29
## Congo :1 3rd Qu.:10.780 3rd Qu.:44.50 3rd Qu.:52.00
## Gabon :1 Max. :39.084 Max. :47.00 Max. :55.00
## (Other) :1
## lifeexpf birthrat deathrat infmr
## Min. :41.00 Min. :28.00 Min. :11.00 Min. : 81.0
## 1st Qu.:48.00 1st Qu.:42.50 1st Qu.:13.50 1st Qu.: 98.5
## Median :56.00 Median :44.00 Median :15.00 Median :110.0
## Mean :52.14 Mean :41.71 Mean :16.14 Mean :115.7
## 3rd Qu.:56.00 3rd Qu.:44.50 3rd Qu.:19.00 3rd Qu.:135.5
## Max. :60.00 Max. :46.00 Max. :22.00 Max. :151.0
##
## fertrate develop gdp
## Min. :5.300 Developing country:0 Min. : 180
## 1st Qu.:5.750 Developed country :7 1st Qu.: 315
## Median :5.800 Median : 950
## Mean :5.814 Mean :1177
## 3rd Qu.:5.900 3rd Qu.:1040
## Max. :6.300 Max. :4400
##
#Different Histogram
chart.Correlation(Na[,2:9,11], histogram=TRUE, pch=19)
#North America observation
Nu<-d%>%filter(country==country, region=="North America")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Nu)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr fertrate
## 1 Argentina 32.901 87.0 67 74 20 9 31 2.8
## 2 Bolivia 7.323 51.0 59 64 34 19 83 5.8
## 3 Brazil 158.000 76.0 62 68 26 7 67 3.2
## 4 Chile 13.528 84.0 71 77 21 6 18 2.7
## 5 Colombia 34.296 65.4 69 74 24 5 37 3.3
## 6 Equador 10.933 54.0 67 72 28 6 60 4.3
## 7 Guyana 0.739 35.0 61 68 21 7 51 2.4
## 8 Paraguay 4.929 46.0 71 74 33 5 28 4.3
## 9 Peru 22.767 70.0 63 67 28 8 59 4.0
## 10 Uruguay 3.121 86.0 69 76 17 10 22 2.5
## 11 Venezuela 20.675 83.0 71 78 28 4 23 3.5
## develop gdp
## 1 Developing country 3100
## 2 Developed country 690
## 3 Developed country 2540
## 4 Developed country 2200
## 5 Developed country 1300
## 6 Developed country 1070
## 7 Developed country 300
## 8 Developed country 1460
## 9 Developed country 920
## 10 Developed country 2935
## 11 Developed country 2590
summary(Nu)
## country pop92 urban lifeexpm lifeexpf
## Argentina:1 Min. : 0.739 Min. :35.00 Min. :59.00 Min. :64
## Bolivia :1 1st Qu.: 6.126 1st Qu.:52.50 1st Qu.:62.50 1st Qu.:68
## Brazil :1 Median : 13.528 Median :70.00 Median :67.00 Median :74
## Chile :1 Mean : 28.110 Mean :67.04 Mean :66.36 Mean :72
## Colombia :1 3rd Qu.: 27.834 3rd Qu.:83.50 3rd Qu.:70.00 3rd Qu.:75
## Equador :1 Max. :158.000 Max. :87.00 Max. :71.00 Max. :78
## (Other) :5
## birthrat deathrat infmr fertrate
## Min. :17.00 Min. : 4.000 Min. :18.00 Min. :2.400
## 1st Qu.:21.00 1st Qu.: 5.500 1st Qu.:25.50 1st Qu.:2.750
## Median :26.00 Median : 7.000 Median :37.00 Median :3.300
## Mean :25.45 Mean : 7.818 Mean :43.55 Mean :3.527
## 3rd Qu.:28.00 3rd Qu.: 8.500 3rd Qu.:59.50 3rd Qu.:4.150
## Max. :34.00 Max. :19.000 Max. :83.00 Max. :5.800
##
## develop gdp
## Developing country: 1 Min. : 300
## Developed country :10 1st Qu.: 995
## Median :1460
## Mean :1737
## 3rd Qu.:2565
## Max. :3100
##
#Different Histogram
chart.Correlation(Nu[,2:9,11], histogram=TRUE, pch=19)
#USSR Observation
Uss<-d%>%filter(country==country, region=="USSR")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Uss)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr
## 1 Australia 17.567 85 74 80 15 8 8
## 2 New Zealand 3.347 76 72 80 15 8 10
## 3 Papua New Guinea 4.006 15 55 56 34 11 55
## fertrate develop gdp
## 1 1.8 Developed country 18054
## 2 1.8 Developed country 14000
## 3 NA Developed country 800
summary(Uss)
## country pop92 urban lifeexpm
## Australia :1 Min. : 3.347 Min. :15.00 Min. :55.0
## New Zealand :1 1st Qu.: 3.676 1st Qu.:45.50 1st Qu.:63.5
## Papua New Guinea:1 Median : 4.006 Median :76.00 Median :72.0
## Afghanistan :0 Mean : 8.307 Mean :58.67 Mean :67.0
## Albania :0 3rd Qu.:10.787 3rd Qu.:80.50 3rd Qu.:73.0
## Algeria :0 Max. :17.567 Max. :85.00 Max. :74.0
## (Other) :0
## lifeexpf birthrat deathrat infmr fertrate
## Min. :56 Min. :15.00 Min. : 8.0 Min. : 8.00 Min. :1.8
## 1st Qu.:68 1st Qu.:15.00 1st Qu.: 8.0 1st Qu.: 9.00 1st Qu.:1.8
## Median :80 Median :15.00 Median : 8.0 Median :10.00 Median :1.8
## Mean :72 Mean :21.33 Mean : 9.0 Mean :24.33 Mean :1.8
## 3rd Qu.:80 3rd Qu.:24.50 3rd Qu.: 9.5 3rd Qu.:32.50 3rd Qu.:1.8
## Max. :80 Max. :34.00 Max. :11.0 Max. :55.00 Max. :1.8
## NA's :1
## develop gdp
## Developing country:0 Min. : 800
## Developed country :3 1st Qu.: 7400
## Median :14000
## Mean :10951
## 3rd Qu.:16027
## Max. :18054
##
#Oceania observation
Oc<-d%>%filter(country==country, region=="USSR")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Oc)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr
## 1 Australia 17.567 85 74 80 15 8 8
## 2 New Zealand 3.347 76 72 80 15 8 10
## 3 Papua New Guinea 4.006 15 55 56 34 11 55
## fertrate develop gdp
## 1 1.8 Developed country 18054
## 2 1.8 Developed country 14000
## 3 NA Developed country 800
summary(Oc)
## country pop92 urban lifeexpm
## Australia :1 Min. : 3.347 Min. :15.00 Min. :55.0
## New Zealand :1 1st Qu.: 3.676 1st Qu.:45.50 1st Qu.:63.5
## Papua New Guinea:1 Median : 4.006 Median :76.00 Median :72.0
## Afghanistan :0 Mean : 8.307 Mean :58.67 Mean :67.0
## Albania :0 3rd Qu.:10.787 3rd Qu.:80.50 3rd Qu.:73.0
## Algeria :0 Max. :17.567 Max. :85.00 Max. :74.0
## (Other) :0
## lifeexpf birthrat deathrat infmr fertrate
## Min. :56 Min. :15.00 Min. : 8.0 Min. : 8.00 Min. :1.8
## 1st Qu.:68 1st Qu.:15.00 1st Qu.: 8.0 1st Qu.: 9.00 1st Qu.:1.8
## Median :80 Median :15.00 Median : 8.0 Median :10.00 Median :1.8
## Mean :72 Mean :21.33 Mean : 9.0 Mean :24.33 Mean :1.8
## 3rd Qu.:80 3rd Qu.:24.50 3rd Qu.: 9.5 3rd Qu.:32.50 3rd Qu.:1.8
## Max. :80 Max. :34.00 Max. :11.0 Max. :55.00 Max. :1.8
## NA's :1
## develop gdp
## Developing country:0 Min. : 800
## Developed country :3 1st Qu.: 7400
## Median :14000
## Mean :10951
## 3rd Qu.:16027
## Max. :18054
##
#Caribbean observation
Ca<-d%>%filter(country==country, region=="USSR")%>%
group_by(country,pop92,urban,lifeexpm,lifeexpf,birthrat,deathrat,infmr,fertrate,develop)%>%summarise(gdp=sum(gdp))%>%ungroup()
data.frame(Ca)
## country pop92 urban lifeexpm lifeexpf birthrat deathrat infmr
## 1 Australia 17.567 85 74 80 15 8 8
## 2 New Zealand 3.347 76 72 80 15 8 10
## 3 Papua New Guinea 4.006 15 55 56 34 11 55
## fertrate develop gdp
## 1 1.8 Developed country 18054
## 2 1.8 Developed country 14000
## 3 NA Developed country 800
summary(Ca)
## country pop92 urban lifeexpm
## Australia :1 Min. : 3.347 Min. :15.00 Min. :55.0
## New Zealand :1 1st Qu.: 3.676 1st Qu.:45.50 1st Qu.:63.5
## Papua New Guinea:1 Median : 4.006 Median :76.00 Median :72.0
## Afghanistan :0 Mean : 8.307 Mean :58.67 Mean :67.0
## Albania :0 3rd Qu.:10.787 3rd Qu.:80.50 3rd Qu.:73.0
## Algeria :0 Max. :17.567 Max. :85.00 Max. :74.0
## (Other) :0
## lifeexpf birthrat deathrat infmr fertrate
## Min. :56 Min. :15.00 Min. : 8.0 Min. : 8.00 Min. :1.8
## 1st Qu.:68 1st Qu.:15.00 1st Qu.: 8.0 1st Qu.: 9.00 1st Qu.:1.8
## Median :80 Median :15.00 Median : 8.0 Median :10.00 Median :1.8
## Mean :72 Mean :21.33 Mean : 9.0 Mean :24.33 Mean :1.8
## 3rd Qu.:80 3rd Qu.:24.50 3rd Qu.: 9.5 3rd Qu.:32.50 3rd Qu.:1.8
## Max. :80 Max. :34.00 Max. :11.0 Max. :55.00 Max. :1.8
## NA's :1
## develop gdp
## Developing country:0 Min. : 800
## Developed country :3 1st Qu.: 7400
## Median :14000
## Mean :10951
## 3rd Qu.:16027
## Max. :18054
##